<template>
  <view>

    <u-sticky>
      <view class="tabs_box">
        <u-tabs :list="list" :is-scroll="true" :current="current" @change="change" active-color="#FFA844"
                inactive-color="#999999" :active-item-style="{ color: '#303133' }" bar-height="10"></u-tabs>
      </view>
    </u-sticky>
    <!--订单提示-->
    <view class="order_tip_wrap">
      <view>1、请在营业可用时间到店；购买后需在倒计时内到店核销并上传笔记；驳回后必须在规定时间内修改并上传笔记，超时将自动取消且无法恢复。</view>
      <view>2、探店订单及名片，一般在提交后当天完成审核，订单审核通过后补贴立即到账。</view>
    </view>
    <view v-if="order_item.check_time == 1" style="height: 100%;width: 100%;position: fixed"
          @click.passive="setMore(order_item)">
    </view>

    <view class="order_list_wrap" v-if="orderList.length != 0">
      <view class="order_list_item" v-for="(item,index) in orderList" :key="index">
        <view class="order_title u-flex">
          <view class="shop_title u-flex" @click="copy_no(item.order_no)">
            <text class="text-Omit">订单号：</text>
            <text class="text-Omit">{{ item.order_no }}</text>
            <image :src="imgurlBwc+'/order/copy@2x.png'" style="margin-left: 10rpx"></image>
          </view>

          <view class="status">
            <!--
              1待付款
              2已付款
              3已核验（等待上传）
              4待审核（已上传）
              5已完成
              -1已取消(超时、自动)
              -2已驳回（审核失败）
              -3已退款（金额原路返回）
            -->
            <text class="color1" v-if="item.status == 1">待付款</text>
            <text class="color1" v-if="item.status == 2">待使用</text>
            <text class="color1" v-if="item.status == 3">已核销，待上传笔记</text>
            <text class="color2" v-if="item.status == 4">审核中</text>
            <text class="color2" v-if="item.status == 5">已完成</text>
            <text class="color2" v-if="item.status == 6">待返款</text>
            <text class="color1" v-if="item.status == 7">任务失效</text>
            <text class="color1" v-if="item.status == 8">订单已超时,任务失效</text>
            <text class="color1" v-if="item.status == -1">已取消</text>
            <text class="color1" v-if="item.status == -2">已驳回</text>
            <text class="color1" v-if="item.status == -3">已退款</text>
          </view>
        </view>
        <view v-if="item.status == 1 || item.status == 2 || item.status == 3 || item.status == -2" class="count_down" style="padding-top: 20rpx;font-size: 24rpx;color: #888888;">
          请在
          <u-count-down
              v-if="item.status == 1 || item.status == 2 || item.status == 3 || item.status == -2"
              :timestamp="findcountdown(item)"
              :show-days="true"
              :show-border="true"
              font-size="24"
              color="#FF402F"
              bgColor="#fff"
              border-color="#ffffff"
              separator="zh"
              separator-size="20"
              separator-color="#FF4E0D">
          </u-count-down>
          <text v-if="item.status == 1">内支付，过期订单将自动取消</text>
          <text v-if="item.status == 2">内到店核销使用，超时自动取消</text>
          <text v-if="item.status == 3">内上传笔记,过期将无法提交！</text>
          <text v-if="item.status == -2">内重新提交笔记，过期将无法提交！</text>
        </view>
        <view style="padding: 20rpx 0"><u-line color="#F3F3F3"></u-line></view>
        <view class="goods_info u-flex">
          <view class="goods_img">
            <image :src="packageimage(item.package.images)" mode="aspectFill"></image>
          </view>
          <view class="goods_name">
            <view>
              <image style="height: 28rpx;width: 28rpx" :src="BestImgUrl+'/index/Frame.png'"></image>
              <text style="font-size: 24rpx;color: #AAAAAA;margin-left: 10rpx">{{ item.shop.name }}</text>
            </view>
            <view style="font-size: 28rpx;color: #333333;margin-top: 10rpx">{{ item.package_name }}</view>
            <view style="font-size: 24rpx;color: #999999;margin-top: 10rpx">
              营业时间：{{ item.shop.open_time }}-{{ item.shop.close_time }}
            </view>
            <view class="u-flex" style="margin-top: 10rpx;font-size: 22rpx">
              <view style="border: 2rpx solid #fd5647;border-radius: 10rpx;" class="u-flex">
                <view style="background-color: #fd5647;border-radius: 10rpx;padding: 6rpx 10rpx;color: #FFFFFF;">
                  先付后返
                </view>
                <view style="color: #fd5647;margin: 0 6rpx">{{ item.price }}返{{ item.rebate_amount }}</view>
              </view>
              <view style="width: 10rpx"></view>
              <text v-if="item.platform_type.platformType===1 || item.platform_type===1"
                    style="border: 2rpx solid #FF7A00;border-radius: 10rpx;color: #FF7A00;padding:6rpx 10rpx;">小红书
              </text>
              <text v-if="item.platform_type.platformType===3 || item.platform_type===3"
                    style="border: 2rpx solid #FF7A00;border-radius: 10rpx;color: #FF7A00;padding:6rpx 10rpx;">大众点评
              </text>
              <!--              <text v-if="item.shop.type===2" style="border: 2rpx solid #FF7A00;border-radius: 10rpx;color: #FF7A00;padding:6rpx 10rpx;">小红书</text>-->
              <!--              <text v-if="item.shop.type===4" style="border: 2rpx solid #FF7A00;border-radius: 10rpx;color: #FF7A00;padding:6rpx 10rpx;">大众点评</text>-->
              <!--              <view style="width: 38rpx"></view>-->
            </view>

            <!--            <view>下单时间：{{item.create_time}}</view>-->
            <!--            <view class="u-flex">探店奖励：付{{item.price}}返{{item.rebate_amount}}<span>¥{{item.price}}</span></view>-->
          </view>
        </view>
        <view
            style="background-color: #f9f9f9;font-size: 24rpx;color: #3d3d3d;border-radius: 10rpx;padding: 20rpx;margin-bottom: 20rpx">
          <view class="u-flex">
            <view style="width: 100rpx;">使用规则</view>
            <view style="font-size: 24rpx;color: #3D3D3D;margin-left: 16rpx;flex: 1">
              <text v-if="item.is_reservation == 2" style="color: #fd6a00;">免预约 | 无需预约</text>
              <text v-if="item.is_reservation == 1" style="color: #fd6a00;">需预约</text>
              <text>{{item.weekStuta}}</text>
              均可使用
            </view>
          </view>
          <view class="u-flex" style="margin-top: 10rpx;position: relative;" @click="detail(item)">
            <view style="width: 100rpx;flex: 1">笔记要求</view>
            <view v-if="item.is_multi_platform > 0" style="font-size: 24rpx;color: #3D3D3D;margin-left: 16rpx;flex: 4">
              发布真实体验
              <view v-for="(noteItem,noteIndex) in item.note_platforms" :key="noteIndex" style="display: inline-block;font-size: 24rpx;">
                {{ noteItem.title }}
                <text v-if="noteIndex !== item.note_platforms.length - 1" style="padding: 0">+</text>
              </view>
              笔记
            </view>
            <view v-else style="font-size: 24rpx;color: #3D3D3D;margin-left: 16rpx;flex: 4">
              发布真实体验{{item.platform_type.platformType === 3 ? "大众点评" : "小红书" }}笔记
            </view>
            <view style="color: #999999;margin-left: 10rpx">详情</view>
            <image :src="imgurlBwc+'/order/right@2x.png'"
                   style="margin-left: 10rpx;height: 21rpx;width: 12rpx;margin-top: 2rpx"></image>
            <view class="mustSee" style="color: white;font-size: 22rpx">必看</view>
          </view>
          <view class="u-flex" style="margin-top: 10rpx">
            <view style="width: 100rpx;flex: 1">参与时间</view>
            <view style="color: #999999;margin-left: 15rpx;flex: 5">{{ item.create_time }}</view>
          </view>
          <view class="u-flex" style="margin-top: 10rpx" @click="Daohang()">
            <view style="width: 100rpx;">门店地址</view>
            <view style="margin-left: 15rpx;flex: 5;display: flex;align-items: center">
              <view style="color: #999999;">{{ item.shop.address }}</view>
              <image :src="imgurlBwc+'/order/right@2x.png'"
                     style="margin-left: 10rpx;height: 21rpx;width: 12rpx;margin-top: 2rpx"></image>
            </view>
          </view>
        </view>
        <view class="bohui_yin u-flex" v-if="item.check_refuse_reason && item.status == -2">
          <view>驳回原因：</view>
          <view>{{ item.check_refuse_reason }}</view>
        </view>
        <view class="bohui_yin u-flex" v-if="item.status == 7">
          <view>失效原因：</view>
          <view>超时未发布笔记或未上传笔记，任务到期未完成自动取消</view>
        </view>
        <view class="bohui_yin u-flex" v-if="item.status == 8">
          <view>失效原因：</view>
          <view>订单已超时，如需使用请联系客服</view>
        </view>
        <view class="order_btnzu u-flex">
          <view class="lxkefu u-flex" style="position: relative">
            <button type="default" @click="setMore(item)" v-if="item.status == 1||item.status == 2">
              <view style="color: #999999">更多</view>
            </button>
            <view style=" width: 144rpx;height: 56rpx;line-height: 56rpx;color: #333333;background: #FFFFFF;
        box-shadow: 0 6rpx 16rpx 0 rgba(0,0,0,0.1);border: 2rpx solid #F0F0F0;text-align: center;position: absolute;left: 0;bottom: -60rpx" v-if="item.check_time == 1" @click="clickMore(item)">{{ item.status == 1 ? '取消订单' : '订单退款' }}</view>
            <view v-if="item.status == 5" style="color: #FF5748;font-size: 28rpx">返款金额：￥{{ item.rebate_amount }}</view>
            <view v-if="item.status == -3" style="color: #FF5748;font-size: 28rpx">
              退款金额：￥{{ item.price }}
              <view style="color: #888888;font-size: 24rpx">钱款已原路返回至你原支付账户</view>
            </view>
            <view v-if="item.status == 6" style="color: #FF5748;font-size: 28rpx">待返款金额：￥{{ item.rebate_amount }}</view>
          </view>
          <view class="right_zu u-flex">

            <!--            <view class="kongxin" @click="quxiao(item)" v-if="item.more">取消订单</view>-->
            <!--            <view class="kongxin" @click="tuikuan(item)" v-if="item.status == 2">订单退款</view>-->

            <view class="kongxin" @click="ToTDDetails(item)" v-if="item.status == -2 || item.status == -3">订单详情</view>
            <view class="kongxin" @click="ToAddImg(item)" v-if="item.status == 5 && item.showcase.length == ''" style="color: #FF7800;border-color: #FF7800">晒图</view>
            <view class="kongxin" @click="telCS(item.shop.tel)" v-if="item.status == 6 || item.status == 8">联系客服</view>
            <view class="kongxin" @click="tuikuan(item)" v-if="item.status == 8">申请退款</view>
            <view class="shise" @click="ToAddOrder(item.shop_package_id)" v-if="item.status == 4 || item.status == 5 || item.status == 7 || item.status == 8 || item.status == -3">再抢一单</view>
            <!--            <view class="shise" @click="YiJianCuiShen(item)" v-if="item.status == 4">一键催审</view>-->
            <view class="shise" @click="toUploadNote(item)" v-if="item.status == -2">重新上传
            </view>

            <view class="shise" @click="toUse(item)" v-if="item.status == 2 && item.shop.check_method == 0">自主核销</view>
            <view class="shise" @click="ToTDDetails(item)" v-if="item.status == 2">到店用餐</view>

            <view class="shise" @click="toUploadNote(item)" v-if="item.status == 3">上传笔记</view>
            <view class="shise" @click="ToAddOrder(item.shop_package_id)" v-if="item.status == -1">重新报名</view>


            <!-- <view class="shise" @click="heyanmoni(item)" v-if="item.status == 2">核验模拟</view> -->

            <!--
              1待付款
              2已付款
              3已核验（等待上传）
              4待审核（已上传）
              5已完成
              -1已取消(超时、自动)
              -2已驳回（审核失败）
              -3已退款（金额原路返回）
            -->
            <view class="shise" v-if="item.status == 1" @click="ToDetails(item)">继续支付</view>
            <!-- <view class="shise" v-if="item.status == 2">去使用</view>
            <view class="shise" v-if="item.status == 3">去上传</view> -->

          </view>

        </view>
      </view>
    </view>
    <view v-else class="noDatas">
      <u-empty text="暂无订单" mode="favor" icon-size="106"></u-empty>
    </view>
    <!--放弃支付弹窗-->
    <u-popup v-model="cancel_order_popup" mode="center" width="600" border-radius="20">
      <view class="tc_wrap" v-if="order_item">
        <view style="height: 10rpx"></view>
        <view style="font-size: 32rpx;font-weight: bold">真的要放弃
          <text style="color: #FF7A00">￥{{ order_item.rebate_amount }}</text>
          的套餐优惠吗？
        </view>
        <view class="u-flex" style="color: #999999;font-size: 24rpx;margin-top: 30rpx;justify-content: center">
          <u-count-down
              v-if="cancel_order_popup"
              :timestamp="findcountdown(order_item)"
              :show-days="true"
              :show-border="true"
              font-size="20"
              color="#FF4E0D"
              bgColor="#fff"
              border-color="#ffffff"
              separator="zh"
              separator-size="20"
              separator-color="#FF4E0D">
          </u-count-down>
          后自动取消订单
        </view>
        <view
            style="background-color: #f2f2f2;font-size: 24rpx;color: #3d3d3d;border-radius: 10rpx;padding: 20rpx;margin-top: 30rpx;display: flex">
          <image :src="order_item.package.images.length>0?order_item.package.images:''" mode="aspectFill"
                 style="width: 120rpx;height: 120rpx;border-radius: 10rpx"></image>
          <view style="text-align: start">
            <view style="font-size: 28rpx;color: #666666;margin-left: 20rpx;font-weight: bold;width: 100%">
              {{ order_item.shop.name }}
            </view>
            <view style="font-size: 24rpx;color: #AAAAAA;margin-left: 20rpx;margin-top: 20rpx;width: 100%">
              {{ order_item.package_name }}
            </view>
          </view>
        </view>
        <view class="tc_images" style="margin: 20rpx 0;">
          <image :src="imgurlBwc+'/order/cancel@2x.png'" mode="aspectFill"
                 style="top: 0;right: 0;position: absolute"></image>
          <view style="position: relative;text-align: center;padding-top: 30rpx;color: white;font-size: 24rpx">
            <view>￥{{ order_item.rebate_amount }}</view>
            <view>返利</view>
          </view>
          <view style="display: flex">
            <view style="color: #FF9746;margin-top: -6rpx;font-size: 22rpx">
              原价￥{{ order_item.price }}
            </view>
            <view style="flex: 1"></view>
            <view style="color: #FF9746;margin-top: -6rpx;font-size: 22rpx">
              原价￥{{ order_item.price }}
            </view>
          </view>
          <view style="color: #FF6600;margin-top: 56rpx;font-size: 22rpx">
            探店价￥
            <text style="font-size: 39rpx">{{ order_item.price }}</text>
          </view>
        </view>
        <view class="tc_btn_box">
          <view class="lijipay1">
            <u-button hover-class="none" type="info" shape="circle" :ripple="false" @click="cancel(order_item)">
              残忍取消
            </u-button>
          </view>
          <view class="lijipay">
            <u-button hover-class="none" type="info" shape="circle" :ripple="false"
                      @click="ToDetails(order_item)">支付锁定优惠
            </u-button>
          </view>

        </view>
      </view>
    </u-popup>

    <!--收集取消支付原因-->
    <u-popup v-model="isPayment" mode="bottom" :closeable="true" height="50%" border-radius="20">
      <view class="cancel-payment">
        <view class="cancel-payment-top">
          <view class="cancel-payment-title">取消支付原因</view>
          <u-line color="#F3F3F3" hair-line></u-line>
          <view class="cancel-payment-head">请选择取消订单原因</view>
        </view>
        <scroll-view scroll-y="true" class="cancel-payment-content">
          <u-radio-group>
            <u-radio
                @change="CancelPaymentChange"
                v-for="(item, index) in infoList" :key="index"
                :name="item.title"
                :disabled="item.disabled"
                :label-size="28"
                :icon-size="35"
                active-color="#FF7A00"
            >
              {{item.title}}
            </u-radio>
          </u-radio-group>
        </scroll-view>
        <view class="cancel-payment-bottom">
          <view class="cancel-payment-btn" @click="cancelPayment">确认</view>
        </view>
      </view>
    </u-popup>
    <!--笔记要求弹窗-->
    <u-popup v-model="showAsk" mode="bottom" width="750" border-radius="20" :closeable="true"
             :mask-close-able="false">
      <view style="padding: 30rpx;background: white" v-if="order_item">
        <view class="guanyu_title">笔记要求</view>

        <view style="height: 20rpx"></view>
        <u-line></u-line>
        <view style="height: 20rpx"></view>
        <view style="text-align: start">
          <view style="font-size: 28rpx;margin-top: 10rpx;font-weight: bold">
            在到店体验完成后，按照以下要求发布
            <text v-if="order_item.is_multi_platform == 1">{{order_item.note_platforms.length}}</text>
            篇笔记即可获得
            <text style="color:#FF7800;">{{ order_item.rebate_amount }}</text>
            元现金~
          </view>
          <view
              style="font-size: 26rpx;margin-top: 20rpx;color: #FF7800;background-color: #FFF8E8;padding: 20rpx;border-radius: 20rpx">
            Tips:图片是重点!可参考领食惠探店实拍和探友晒图哦~
          </view>
          <view style="font-size: 26rpx;margin-top: 20rpx;;font-weight: bold;display: flex">
            <view>笔记平台:</view>
            <view v-if="order_item.is_multi_platform == 1" v-for="(item,index) in order_item.note_platforms" :key="index">
              {{item.title}}
              <text v-if="index != order_item.note_platforms.length - 1" style="padding: 0">+</text>
            </view>
            <view v-if="order_item.is_multi_platform == 0">{{order_item.platform_type.title}}</view>
          </view>
          <view style="font-size: 26rpx;margin-top: 20rpx;font-weight: bold">笔记图片</view>
          <view style="font-size: 24rpx;margin-top: 10rpx;color: #AAAAAA"> {{ order_item.activity_ask }}</view>
          <view style="font-size: 26rpx;margin-top: 20rpx;">
            <view style="font-weight: bold">携带话题</view>
            <view style="height: 10rpx"></view>
            <text v-for="(subItem,idx) in order_item.package.subject" :key="idx" style="color: #FF7800">{{ subItem.name }}</text>
            <text style="height: 10rpx;color: #cccccc">+2个热门自选话题</text>
          </view>
          <view style="font-size: 26rpx;margin-top: 20rpx;font-weight: bold">添加门店定位</view>
          <view style="font-size: 24rpx;margin-top: 10rpx;color: #FF7800" @click="Daohang()">{{
              order_item.shop.address
            }}
          </view>
        </view>

        <view style="height: 60rpx"></view>
        <view style="width: 690rpx;height: 80rpx;background: linear-gradient( 104deg, #FF7800 0%, #FF7A00 100%);
              font-size: 32rpx;color: #FFFFFF;line-height: 80rpx;text-align: center;border-radius: 60rpx"
              @click="showAsk=false">
          确定
        </view>
        <view style="height: 20rpx"></view>
      </view>
    </u-popup>
  </view>
</template>

<script>
const app = getApp();
export default {
  data() {
    return {
      BestImgUrl: app.globalData.imgurl,
      imgurlBwc: app.globalData.imgurlBwc,
      cancel_order_popup: false,
      isPayment: false, // 取消支付原因是否显示
      //取消支付原因列表
      infoList: [
        {
          id: 1,
          title: '计划有变没时间消费'
        },
        {
          id: 2,
          title: '买多了/买错了'
        },
        {
          id: 3,
          title: '后悔了，不想要'
        },
        {
          id: 4,
          title: '不会/不想写探店笔记'
        },
        {
          id: 5,
          title: '其他平台/店里活动更优惠'
        },
        {
          id: 6,
          title: '没看清使用规则，要用时发现限制很多'
        },
        {
          id: 7,
          title: '误以为是外卖'
        },
        {
          id: 8,
          title: '预约不上/排队太久'
        },
        {
          id: 9,
          title: '朋友/网上评价不好'
        },
        {
          id: 10,
          title: '商家停业/装修/转让'
        }
      ],
      more: false,
      showAsk: false,
      order_item: {
        package: {
          images: []
        },
        shop: {
          name: ''
        },
        package_name: ''
      },
      typeList: [
          {
            name: '探店订单',
            id: 0
          }, {
            name: '捡漏订单',
            id: 1
          }, {
            name: '砍价订单',
            id: 1
          }],
      typeIdx: 0,
      //全部- 2待使用- 3待上传- -2已驳回- 4待审核- 6待返款- 5已完成- 1待付款- -3已退款- -1已取消
      list: [
        {
          name: '全部',
          id: 0
        },
        {  // 进行中包括 待使用2、待上传3、待审核4、 已驳回-2
          name: '进行中',
          id: 10
        },
        {
          name: '待付款',
          id: 1
        },
        { // 已结束包括 已退款-3、已取消-1
          name: '已结束',
          id: 11
        },
        {
          name: '已完成',
          id: 5
        }
      ],
      current: 0,
      orderList: [],
      typs: '0',//0全部 1待付款 2已付款 3上传 4待审核
      pageSize: 1,
      // 平台数据
      platformData: [
        {
          platformType: 1,
          title: '小红书',
          image: '/note/xhs@2x.png',
          fileList: [],
        },
        {
          platformType: 2,
          title: '抖音',
          image: '/note/douyin@2x.png',
          fileList: [],
        },
        {
          platformType: 3,
          title: '大众点评',
          image: '/note/dzdp@2x.png',
          fileList: [],
        },
        {
          platformType: 4,
          title: '美团',
          image: '/note/mt@2x.png',
          fileList: [],
        },
      ],

    }
  },
  onLoad(ops) {
    let that = this
    //  出现“当前店铺存在未支付订单”，则跳转到订单待付款列表
    if (uni.getStorageSync('ObligationFun')){
      console.log('当前店铺存在未支付订单', that.current)
      that.current = uni.getStorageSync('ObligationFun')//待付款tabs的下标
      that.typs = 1 //待付款状态码
      that.orderList = []
      that.pageSize = 1
      that.GetOrderslist(that.typs)
    }else{
      that.typs = ops.types || "0"
      console.log("that.typs",that.typs)
      that.GetOrderslist(ops.types)

      uni.$on('orderRef', (val) => {
        that.GetOrderslist(val)
      });
    }
    // 页面返回页数重置第一页
    if (ops.page){
      that.pageSize = ops.page
    }
  },
  //下拉刷新
  onPullDownRefresh() {
    let that = this
    that.pageSize = 1
    setTimeout(function () {
      that.Getorders();
      uni.stopPullDownRefresh();
    }, 1500);
  },
  //触底加载
  onReachBottom() {
    let that = this
    setTimeout(function () {
      that.pageSize++;
      that.Getorders();
      uni.hideNavigationBarLoading()
    }, 500);
  },
  onShow() {
    let that = this
    let token = uni.getStorageSync('token')
    if (!token) {
      that.orderList = []
    }
    that.GetOrderslist()
  },
  methods: {
    toUse(item){
      let that = this
      uni.showModal({
        title: '提示',
        content: '确定您已到店并需自主核销，核销后代表该订单您已消费；不可退款。如未消费请取消；避免售后问题。',
        confirmColor: '#FF4910',
        cancelText: '取消核销',
        confirmText: '确定核销',
        success: function (res) {
          if (res.confirm) {
            //console.log('用户点击确定');
            that.$api.TDheyanmoniOrder({
              order_id: item.id
            }).then(resss => {
              that.pageSize = 1
              that.Getorders()
            }).catch(err => {
              uni.showToast({
                title: err.data.msg,
                icon: 'none',
                duration: 2000
              });
            })
          } else if (res.cancel) {
            //console.log('用户点击取消');
          }
        }
      });
    },
    clickMore(item) {
      if (item.status == 1) {
        this.quxiao(item)
      } else {
        this.tuikuan(item)
      }
    },
    setMore(item){
      if(this.order_item.id !== item.id){
        console.log("11111111111111111111111",item)
        this.order_item.check_time = 2
        item.check_time = 1
      }else{
        if(item.check_time == 1){
          item.check_time = 2
        }else{
          item.check_time = 1
        }
        console.log("222222222222222222222",item)
      }
      this.order_item = item
      console.log("setMore1",item)
      // this.orderList[index].more =  !this.orderList[index].more
      // this.orderList.push()
      // item.more = !item.more
      // console.log("setMore",item)
    },

    Daohang() {
      wx.openLocation({
        latitude: Number(this.order_item.shop.latitude),
        longitude: Number(this.order_item.shop.longitude),
        scale: 18,
        name: this.order_item.shop.name,
        address: this.order_item.shop.address
      });
    },
    GetOrderslist(type) {
      let that = this
      if (type == 0) {
        that.current = 0 //全部
      } else if (type == 1) {
        that.current = 1 //待付款
      } else if (type == 10) {
        that.current = 10 //进行中
      } else if (type == 11) {
        that.current = 11 //已结束
      } else if (type == 5) {
        that.current = 5 //已完成
      }
      that.Getorders();
    },
    Getorders() {
      let that = this
      that.$api.GetTanDianOrder({
        page: that.pageSize,
        limit: 10,
        status: that.typs
      }).then(res => {
        // 处理平台数据
        res.data.result.forEach((item, index) => {
          if(item.is_multi_platform){
            const noteArr = []
            const note = JSON.parse(item.note_platforms)
            note.forEach((item2, index2) => {
              that.platformData.forEach((item3, index3) => {
                if (item3.platformType == item2) {
                  noteArr.push({
                    platformType: item3.platformType,
                    title: item3.title,
                    image: that.imgurlBwc + item3.image,
                  })
                }
              })
            })
            item.note_platforms = noteArr
          } else {
            that.platformData.forEach((item3, index3) => {
              if (item3.platformType == item.platform_type) {
                item.platform_type = {
                  platformType: item3.platformType,
                  title: item3.title,
                  image: that.imgurlBwc + item3.image,
                }
              }
            })
          }
        })

        console.log('订单列表', res.data.result);
        if (that.pageSize != 1) {
          if (res.data.result.length != 0) {
            that.orderList = that.orderList.concat(res.data.result)

            if (that.orderList.length > 0) {
              that.order_item = that.orderList[0]
              that.orderList.forEach(function (item) {
                item.more = 0
              })
              console.log('item.more', that.order_item)
            }
          } else {

          }
        } else {
          that.orderList = res.data.result
          if (that.orderList.length > 0) {
            that.order_item = that.orderList[0]
            that.orderList.forEach(function (item) {
              item.more = 0
            })
            console.log('item.more', that.order_item)
          }
        }
        //使用规则动态赋值
        that.orderList.forEach((item) => {
          //console.log('week', item.package.week)
          //把数组字符串转换为数组数字
          let weekArr = item.package.week.map(item => parseInt(item))
          //改变数据类型
          const weekData = weekArr.map(num => ({
            1: {title: '一', num: '1'},
            2: {title: '二', num: '2'},
            3: {title: '三', num: '3'},
            4: {title: '四', num: '4'},
            5: {title: '五', num: '5'},
            6: {title: '六', num: '6'},
            7: {title: '日', num: '7'}}[num]));
          let weekMax = ''
          let weekMin = ''
          //判断是否连续
          if(this.isArrayContinuous(weekArr)){
            weekData.forEach((itemWeek) => {
              if (itemWeek.num == Math.max(...weekArr)) {
                weekMax = "星期"+itemWeek.title
              } else if(itemWeek.num == Math.min(...weekArr)) {
                weekMin = "星期"+itemWeek.title
              }
            });
            item.weekStuta = weekMin + "到" + weekMax
            //console.log('是连续数字',that.weekList)
          }else{
            item.weekStuta = ''
            weekData.forEach((itemWeek) => {
              item.weekStuta += "星期"+itemWeek.title+","
            })
            item.weekStuta = item.weekStuta.replace('undefined','')
            //console.log('不是连续数字')
          }
        })
      }).catch(err => {
      })
    },
    //计算数组是否连续
    isArrayContinuous(arr) {
      const min = Math.min(...arr);
      const max = Math.max(...arr);
      const expectedLength = max - min + 1; // 计算理论上应有的长度
      const seen = new Set(arr); // 使用Set来记录已经出现的数字

      // 检查是否所有数字都出现过
      for (let i = min; i <= max; i++) {
        if (!seen.has(i)) {
          return false;
        }
      }
      return true;
    },
    //倒计时计算
    findcountdown(item) {
      const now = new Date().getTime();
      // 待付款倒计时
      if (item.status == 1){
        let endTime = new Date(item.end_time).getTime()
        let isend = endTime - now > 0 ? (endTime - now) : 0;
        let seconds = this.$moment(isend).unix();
        // console.log('结束时间', seconds)
        return seconds
      }
      //待到店使用倒计时
      else if (item.status == 2) {
        let invalidTime = new Date(item.invalid_date).getTime()
        let isend = invalidTime - now > 0 ? (invalidTime - now) : 0;
        let seconds = this.$moment(isend).unix();
        // console.log('结束时间', seconds)
        return seconds
      }
      // 待上传笔记倒计时
      else if (item.status == 3) {
        let expiryTime = new Date(item.expiry_date).getTime()
        let isend = expiryTime - now > 0 ? (expiryTime - now) : 0;
        let seconds = this.$moment(isend).unix();
        // console.log('结束时间', seconds)
        return seconds
      }
      // 驳回倒计时
      else if (item.status == -2) {
        let expiryTime = new Date(item.expiry_date).getTime()
        let isend = expiryTime - now > 0 ? (expiryTime - now) : 0;
        let seconds = this.$moment(isend).unix();
        // console.log('结束时间', seconds)
        return seconds
      }
    },
    packageimage(data) {
      return data[0]
    },
    change(item) {
      console.log('item', item)
      this.current = item.index;
      this.typs = this.list[item.index].id
      this.orderList = []
      this.pageSize = 1
      this.Getorders()
    },
    copy_no(order_no) {
      uni.setClipboardData({
        data: order_no, // e是你要保存的内容
        success: function () {
          uni.showToast({
            title: '复制成功',
            icon: 'none'
          })
        }
      });
    },
    typeChange(index) {
      this.typeIdx = index;
    },
    ToDetails(item) {
      this.cancel_order_popup = false
      uni.navigateTo({
        url: '/subpackageA/pages/OrderDetails/OrderDetails?data=' + encodeURIComponent(JSON.stringify(item))
      })
    },
    ToTDDetails(item) {
      uni.navigateTo({
        url: '/subpackageA/pages/TanDianProcess/TanDianProcess?data=' + encodeURIComponent(JSON.stringify(item))
      })
    },
    YiJianCuiShen(item) {

    },
    detail(data) {
      let that = this
      that.order_item = data
      that.showAsk = true
    },
    quxiao(data) {
      let that = this
      data.check_time = 2
      that.order_item = data
      that.cancel_order_popup = true
      /* uni.showModal({
         title: '提示',
         content: '是否要取消此订单?',
         confirmColor: '#FF4910',
         success: function (res) {
           if (res.confirm) {
             //console.log('用户点击确定');
             that.$api.TDquxiaoOrder({
               order_id: data.id
             }).then(resss => {
               that.Getorders()
             }).catch(err => {
               uni.showToast({
                 title: err.data.msg,
                 icon: 'none',
                 duration: 2000
               });
             })
           } else if (res.cancel) {
             //console.log('用户点击取消');
           }
         }
       });*/
    },
    cancel(data) {
      let that = this
      that.cancel_order_popup = false
      //console.log('用户点击确定');
      that.$api.TDquxiaoOrder({
        order_id: data.id
      }).then(resss => {
        that.Getorders()
      }).catch(err => {
        uni.showToast({
          title: err.data.msg,
          icon: 'none',
          duration: 2000
        });
      })
    },
    tuikuan(data) {
      let that = this
      uni.showModal({
        title: '提示',
        content: '是否要操作退款?',
        confirmColor: '#FF4910',
        success: function (res) {
          if (res.confirm) {
            //console.log('用户点击确定');
            that.$api.TDtuikuanOrder({
              order_id: data.id
            }).then(resss => {
              uni.showToast({
                title: '退款成功',
                icon: 'none',
                duration: 2000
              })
              that.pageSize = 1
              that.Getorders()
            }).catch(err => {
              uni.showToast({
                title: err.data.msg,
                icon: 'none',
                duration: 2000
              });
            })
          } else if (res.cancel) {
            //console.log('用户点击取消');
          }
        }
      });
    },
    heyanmoni(data) {
      let that = this
      uni.showModal({
        title: '提示',
        content: '确定模拟核验订单?',
        confirmColor: '#FF4910',
        success: function (res) {
          if (res.confirm) {
            //console.log('用户点击确定');
            that.$api.TDheyanmoniOrder({
              order_id: data.id
            }).then(resss => {
              that.Getorders()
            }).catch(err => {
              uni.showToast({
                title: err.data.msg,
                icon: 'none',
                duration: 2000
              });
            })
          } else if (res.cancel) {
            //console.log('用户点击取消');
          }
        }
      });
    },
    contactService() {
      let data = uni.getStorageSync('customerServiceData')
      // #ifdef H5
      window.location.href = data.h5.url
      // #endif

      // #ifdef APP-PLUS
      let appurl = data.app.url
      uni.navigateTo({
        url: '/pages/Webview/Webview?url=' + encodeURIComponent(JSON.stringify(appurl))
      })
      // #endif
    },
    // 上传笔记
    toUploadNote(res) {
      uni.navigateTo({
        url: '/sub_account/pages/upload_note?data=' + encodeURIComponent(JSON.stringify(res)) +  '&source=pageSource'
      })
    },
    //  晒图
    ToAddImg(data) {
      uni.navigateTo({
        url: '/sub_account/pages/add_shaitu?data=' + encodeURIComponent(JSON.stringify(data)) + '&source=pageSource'
      })
    },
    //  再抢一单
    ToAddOrder(id) {
      uni.navigateTo({
        url: '/subpackageA/pages/PackageDetails/PackageDetails?package_id=' + id
      })
    },
    //  联系客服
    telCS(phone){
      uni.makePhoneCall({
        phoneNumber: phone,
        success: function () {
          console.log('拨打电话成功');
        },
        fail: function () {
          console.log('拨打电话失败');
        }
      })
    },
  }
}
</script>

<style lang="scss">
page {
  background-color: #f4f4f4;
}

/deep/ scroll-view ::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
  color: transparent;
}
/*订单提示css*/
.order_tip_wrap{
  padding: 20rpx 30rpx;
  background: #FFF9F3;
  font-size: 24rpx;
  color: #FF7900;
}
.order_list_wrap {
  padding: 30rpx;

  .order_list_item {
    margin-bottom: 30rpx;
    border-radius: 24rpx;
    padding: 24rpx;
    background-color: #ffffff;
    .order_title {
      align-items: center;
      justify-content: space-between;

      .shop_title {
        align-items: center;

        image {
          width: 32rpx;
          height: 32rpx;
          margin-right: 6rpx;
        }

        text {
          color: $zzy-text-color-999999;
          font-size: 24rpx;
          -webkit-line-clamp: 1;
        }
      }

      .status {
        flex: 1;
        text-align: right;
        font-size: 24rpx;

        .color1 {
          color: #FF4E0D;
        }

        .color2 {
          color: #00AA3B;
        }
      }
    }

    .goods_info {
      align-items: flex-start;

      .goods_img {
        width: 180rpx;
        height: 180rpx;

        image {
          width: 180rpx;
          height: 180rpx;
          border-radius: 16rpx;
        }
      }

      .goods_name {
        padding-left: 16rpx;
        flex: 1;
        margin-bottom: 24rpx;

        view:nth-child(1) {
          font-weight: bold;
          color: $zzy-text-color-333333;
        }

        view:nth-child(2) {
          font-size: 24rpx;
          color: $zzy-text-color-666666;
        }

        view:nth-child(3) {
          align-items: center;
          justify-content: space-between;
          font-size: 24rpx;
          color: $zzy-text-color-666666;
          flex: 1;

          span {
            color: $zzy-text-color-333333;
            font-size: 28rpx;
          }
        }
      }
    }
    // 必看
    .mustSee{
      position: absolute;
      bottom: 30rpx;
      right: -20rpx;
      z-index: 5;
      padding: 5rpx 13rpx;
      color: #FFFFFF;
      font-size: 12rpx;
      border-radius: 16rpx 16rpx 16rpx 0;
      background: linear-gradient(to right, #fc8635 0%, #ec1e2c 100%);
    }
    .bohui_yin {
      border-radius: 16rpx;
      padding: 20rpx;
      background-color: #FCF0ED;
      margin-bottom: 24rpx;
      align-items: flex-start;

      view:nth-child(1) {
        color: #FF4E0D;
      }

      view:nth-child(2) {
        color: $zzy-text-color-666666;
        flex: 1;
      }
    }

    .order_btnzu {
      align-items: center;
      justify-content: space-between;

      .lxkf {
        flex: 1;
        align-items: center;
        color: $zzy-text-color-333333;
        font-size: 24rpx;
      }

      .lxkefu {
        font-size: 24rpx;

        /deep/ button {
          background-color: transparent !important;
          padding: 0 !important;
          margin: 0 !important;
          line-height: 40rpx !important;
          height: 40rpx;
          font-size: 24rpx !important;
          color: #333333 !important;
        }

        /deep/ button::after {
          border: none !important;
        }
      }

      .right_zu {
        .kongxin {
          border-radius: 200rpx;
          width: 144rpx;
          height: 56rpx;
          line-height: 56rpx;
          border: 1px solid #d9d9d9;
          color: $zzy-text-color-333333;
          text-align: center;
          font-size: 24rpx;
          margin-left: 20rpx;
        }

        .shise {
          background-color: #FF7900;
          border-radius: 200rpx;
          width: 144rpx;
          height: 56rpx;
          line-height: 56rpx;
          border: 1px solid #FF7900;
          color: #ffffff;
          text-align: center;
          font-size: 24rpx;
          margin-left: 20rpx;
        }
      }
    }
  }
}

.tc_wrap {
  background: linear-gradient(179deg, #FFF2EA 0%, #FFE5E4 5%, #fdf8f8 20%, #FFFFFF 50%, rgba(255, 255, 255, 0) 100%);;
  padding: 30rpx;
  text-align: center;

  .guanyu_title {
    font-size: 30rpx;
    font-weight: bold;
    margin-bottom: 10rpx;
  }

  .wenan {
    color: #999;
    margin-bottom: 20rpx;
  }

  .tc_images {
    width: 520rpx;
    height: 236rpx;
    position: relative;

    image {
      width: 520rpx;
      height: 236rpx;
    }
  }

  .steup_info {
    text-align: left;
    margin-top: 30rpx;

    .yqoiu {
      view:nth-child(1) {
        color: #666;
      }
    }

    .yqoiu2 {
      color: #666;

      span {
        color: #FE7B20;
      }
    }
  }

  .tc_info {
    view:nth-child(1) {
      font-weight: bold;
      font-size: 32rpx;
      margin-bottom: 20rpx;
    }

    view:nth-child(2) {
      font-size: 28rpx;
      color: #999;

      span {
        color: #FF4E0D;
      }
    }

    .gif_tu {
      width: 100%;
      height: 528rpx;
      border-radius: 20rpx;
    }
  }

  .tc_btn_box {
    display: flex;
    align-items: center;
    margin-top: 36rpx;
    justify-content: center;

    .tc_btn_huise {
      flex: 1;
      margin-right: 12rpx;
      background: linear-gradient(to right, #F7F7F7, 50%, #F7F7F7);
      border-radius: 200rpx;
      padding: 0 0;
      height: 80rpx !important;
      line-height: 80rpx !important;
      text-align: center;
      color: #333333;
    }

    .tc_btn_huise_err {
      flex: 1;
      background-image: linear-gradient(to right, #FF4E0D, #FF4E0D) !important;
      color: #fff;
      border-radius: 200rpx;
      padding: 0 0;
      height: 80rpx !important;
      line-height: 80rpx !important;
      text-align: center;
    }

    .lijipay1 {
      flex: 1;
      position: relative;
      width: 288rpx;
      margin: 0 20rpx 0 0;

      .u-size-default {
        height: 80rpx !important;
        line-height: 80rpx !important;
        background: linear-gradient(to right, #F7F7F7, 50%, #F7F7F7) !important;
        color: #333;
        border: none !important;
      }

      .u-hairline-border:after {
        border: none !important;
      }
    }

    .lijipay {
      flex: 1;
      position: relative;
      width: 288rpx;
      margin: 0 auto;

      .u-size-default {
        height: 80rpx !important;
        line-height: 80rpx !important;
        background-image: linear-gradient(to right, #F18F2C, #FF7A00) !important;
        color: #fff;
        border: none !important;
      }

      .u-hairline-border:after {
        border: none !important;
      }
    }
  }
}
</style>